﻿<%@ Page Language="VB" Inherits="CMS"  MasterPageFile="~/userfiles/mastercms.master" Title="Suche" %>
<%@ import Namespace="System.Data.OLEDB" %>
<%@ import Namespace="System.Data" %>
<%@ Import Namespace="System.Web" %>
<script runat="server">
    
    Dim IntAnzahlMax As Integer = 10
    
    Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs)
               
        Dim str2Search As String = ""
        str2Search = Me.txtSearchString.Text
        abfrageausgabe(str2Search)
        
    End Sub
    
    Private Sub abfrageausgabe(ByVal str2Search As String)
        Dim strCNR As String
        Dim strLinkURL As String
        Dim strLinkText As String
        Dim strContent As String
        Dim strAlink As String
        Dim strSelect As String
        Dim strWhere As String
        strSelect = "cnr,content,linkurl,linktext"
        strWhere = "((tbl_pages.content Like '% " & str2Search & "%')) AND ((tbl_pages.pagetyp Is Null) OR (tbl_pages.pagetyp='Artikel'))"
        Dim Daten As IDataReader = Nothing
        Dim intAnzahl As Integer = 0
        Dim sb As StringBuilder = New StringBuilder()
        sb.Append("<table class=""searchtbl"">")
        Try
            Daten = tbPages.GetDataReader(strSelect, strWhere)
            If Not IsNothing(Daten) Then
                While Daten.Read()
                    If intAnzahl < IntAnzahlMax Then
                        intAnzahl += 1
                    
                        'reader.GetInt32(0) & ", " & reader.GetString(1))
                        strCNR = Daten.GetInt32(0).ToString
                        'strContent = cms2.GetSubstring(cms2.RemoveHTML(CMS.FixDBNull2String(Daten.GetValue(1))), 200)
                        'strLinkURL = cms2.FixDBNull2String(Daten.GetValue(2))
                        'strLinkText = cms2.FixDBNull2String(Daten.GetValue(3))
                        'strAlink = cms2.GetALink(cms2.GetLinkUrl(strCNR, strLinkURL, strLinkText), strLinkText)
                        'strContent = cms2.GetSubstring(cms2.RemoveHTML(Daten.GetValue(1)), 200)
                        strContent = ""
                        strLinkURL = Daten.GetValue(2)
                        strLinkText = Daten.GetValue(3)
                        'strAlink = cms2.GetALink(cms2.GetLinkUrl(strCNR, strLinkURL, strLinkText), strLinkText)
                        strAlink = ""
                        sb.Append("<tr>")
                        sb.Append("<td>")
                        sb.Append(strAlink)
                        sb.Append("</td>")
                        sb.Append("</tr>")
                        sb.Append("<tr>")
                        sb.Append("<td>")
                        sb.Append(strContent)
                        sb.Append("</td>")
                        sb.Append("</tr>")
                        sb.Append("<tr>")
                        sb.Append("<td>")
                        sb.Append(" ")
                        sb.Append("</td>")
                        sb.Append("</tr>")
                    Else
                        Exit While
                    End If
                    
            
                End While
            End If
        Catch ex As Exception
        
        Finally
            If Not IsNothing(Daten) Then
                If Daten.IsClosed = False Then
                    Daten.Close()
                End If
            End If

             
        End Try
 
        sb.Append("</table>")
        suchergebnis.Text = sb.ToString
        
    End Sub
    
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    &nbsp;<asp:TextBox ID="txtSearchString" runat="server"></asp:TextBox>&nbsp;
    <asp:Button ID="btnSearch" runat="server" Text="Suche" OnClick="btnSearch_Click" />
    <asp:Label runat="server" ID="suchergebnis"></asp:Label>

</asp:Content>


